package com.fescoservice.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.fescoservice.model.SeekerLan;
import com.fescoservice.model.SeekerLanId;

/**
 * A data access object (DAO) providing persistence and search support for
 * SeekerLan entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.fescoservice.dao.SeekerLan
 * @author MyEclipse Persistence Tools
 */

public class SeekerLanDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(SeekerLanDAO.class);
	// property constants
	public static final String CHINESE_ABL = "chineseAbl";
	public static final String ENGLISH_ABL = "englishAbl";
	public static final String JAPANESE_ABL = "japaneseAbl";
	public static final String FRECN_ABL = "frecnAbl";
	public static final String GERMEN_ABL = "germenAbl";
	public static final String RUSSIA_ABL = "russiaAbl";
	public static final String SPANISH_ABL = "spanishAbl";
	public static final String KOREA_ABL = "koreaAbl";
	public static final String ARABIC_ABL = "arabicAbl";
	public static final String OTHER_ABL = "otherAbl";
	public static final String MEMO = "memo";

	protected void initDao() {
		// do nothing
	}

	public void save(SeekerLan transientInstance) {
		log.debug("saving SeekerLan instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(SeekerLan persistentInstance) {
		log.debug("deleting SeekerLan instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public SeekerLan findById(SeekerLanId id) {
		log.debug("getting SeekerLan instance with id: " + id);
		try {
			SeekerLan instance = (SeekerLan) getHibernateTemplate().get(
					"com.fescoservice.model.SeekerLan", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(SeekerLan instance) {
		log.debug("finding SeekerLan instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding SeekerLan instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from SeekerLan as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByChineseAbl(Object chineseAbl) {
		return findByProperty(CHINESE_ABL, chineseAbl);
	}

	public List findByEnglishAbl(Object englishAbl) {
		return findByProperty(ENGLISH_ABL, englishAbl);
	}

	public List findByJapaneseAbl(Object japaneseAbl) {
		return findByProperty(JAPANESE_ABL, japaneseAbl);
	}

	public List findByFrecnAbl(Object frecnAbl) {
		return findByProperty(FRECN_ABL, frecnAbl);
	}

	public List findByGermenAbl(Object germenAbl) {
		return findByProperty(GERMEN_ABL, germenAbl);
	}

	public List findByRussiaAbl(Object russiaAbl) {
		return findByProperty(RUSSIA_ABL, russiaAbl);
	}

	public List findBySpanishAbl(Object spanishAbl) {
		return findByProperty(SPANISH_ABL, spanishAbl);
	}

	public List findByKoreaAbl(Object koreaAbl) {
		return findByProperty(KOREA_ABL, koreaAbl);
	}

	public List findByArabicAbl(Object arabicAbl) {
		return findByProperty(ARABIC_ABL, arabicAbl);
	}

	public List findByOtherAbl(Object otherAbl) {
		return findByProperty(OTHER_ABL, otherAbl);
	}

	public List findByMemo(Object memo) {
		return findByProperty(MEMO, memo);
	}

	public List findAll() {
		log.debug("finding all SeekerLan instances");
		try {
			String queryString = "from SeekerLan";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public SeekerLan merge(SeekerLan detachedInstance) {
		log.debug("merging SeekerLan instance");
		try {
			SeekerLan result = (SeekerLan) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(SeekerLan instance) {
		log.debug("attaching dirty SeekerLan instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(SeekerLan instance) {
		log.debug("attaching clean SeekerLan instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static SeekerLanDAO getFromApplicationContext(ApplicationContext ctx) {
		return (SeekerLanDAO) ctx.getBean("SeekerLanDAO");
	}
}